package cn.lzy.taskmanagement.AsyncNotResult;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * @Author: WeiKaiYe
 * @CreateTime: 2023-10-21  17:27
 */

@Service
public class MyAsyncService {
    /**
     * 模拟无返回值的异步任务处理
     */

    @Async
    public void sendSMS() throws Exception {
        System.out.println("调用短信验证码业务方法...");
        Long startTime = System.currentTimeMillis();
        Thread.sleep(5000);  // 代码等待5000毫秒后再执行
        Long endTime = System.currentTimeMillis();
        System.out.println("短信业务执行完成耗时：" + (endTime - startTime));
    }
}
